package hd.util;

import android.graphics.Color;

import java.util.Random;

/**
 * 处理颜色的工具
 * <p/>
 * Created by apple on 14-10-3.
 */
public class ColorUtil {

    /**
     * 使一种颜色变半透明
     *
     * @param alpha 透明度
     * @param color 颜色
     * @return color
     */
    public static int alphaColor(int alpha, int color) {
        int r = (color >> 16) & 0xff;
        int g = (color >> 8) & 0xff;
        int b = color & 0xff;
        return Color.argb(alpha, r, g, b);
    }

    /**
     * 获取随机颜色
     *
     * @return 颜色
     */
    public static int randomColor() {
        Random random = new Random();
        int r = random.nextInt(255);
        int g = random.nextInt(255);
        int b = random.nextInt(255);
        return Color.rgb(r, g, b);
    }

}